package com.wskj.controller.login;

import com.wskj.common.annotation.RepeatSubmit;
import com.wskj.common.core.controller.BaseController;
import com.wskj.common.core.domain.AjaxResult;
import com.wskj.workbench.bo.app.AppTbUserJoinOrderAddBo;
import com.wskj.workbench.bo.app.AppTbUserJoinOrderQueryBo;
import com.wskj.workbench.service.ITbUserJoinOrderService;
import com.wskj.workbench.vo.app.AppTbUserJoinOrderInfoVo;
import com.wskj.workbench.vo.app.AppTbUserJoinOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 用户入驻申请订单Controller
 *
 * @author wskj
 * @date 2024-09-25
 */
@Api(tags = "【用户申请入住】相关接口")
@AllArgsConstructor
@RestController
@RequestMapping("/api/userJoinorder")
public class ApiTbUserJoinOrderController extends BaseController {

    private final ITbUserJoinOrderService iTbUserJoinOrderService;


    /**
     * 用户申请入住
     */
    @ApiOperation("用户申请入住")
    @RepeatSubmit
    @PostMapping("/apply")
    public AjaxResult<AppTbUserJoinOrderVo> apply(@Validated @RequestBody AppTbUserJoinOrderAddBo bo) throws Exception {
        AppTbUserJoinOrderVo apply = iTbUserJoinOrderService.apply(bo);
        return AjaxResult.success(apply);
    }


    /**
     * 查询用户入驻详情接口
     */
    @ApiOperation("查询用户入驻详情接口(第一次入驻被驳回了,通过这个接口去查询入驻信息,因为这个时候用户还没有注册到系统中,userId还不存在所以只能通过手机号去查询)")
    @GetMapping("/join")
    public AjaxResult<AppTbUserJoinOrderInfoVo> join(AppTbUserJoinOrderQueryBo bo) throws Exception {
        AppTbUserJoinOrderInfoVo join = iTbUserJoinOrderService.join(bo);
        return AjaxResult.success(join);
    }


}
